package com.flower8.utils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
import java.util.UUID;

/**
 * @Description:  渠道商工具类
 * @Author: tanglin
 * @Date: 2020/5/20 17:28
 * @Version: 1.0
 */
public class AgentUtils {

    /**
     * 生成渠道编码
     * @return
     */
    public static String createAgentCode(){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        String newDate=sdf.format(new Date());
        int hashCodeV = UUID.randomUUID().toString().hashCode();
        if(hashCodeV < 0) {//有可能是负数
            hashCodeV = - hashCodeV;
        }
        // 0 代表前面补充0，5 代表长度为5，d 代表参数为正数型
        return newDate+String.format("%05d", hashCodeV);
    }


    public static void main(String[] args) {
//        System.out.println(createAgentCode());
        System.out.println("1234"+String.format("%04d", 1));
    }
}
